#ifndef XPMDOC_DAL_DOC_TABLE_ACCESS_H
#define XPMDOC_DAL_DOC_TABLE_ACCESS_H
#include <string>
#include "model/XpmTermDoc.h"
#include "libjson.h"
#include "DocAccess.h"


namespace conex {
	class TermFactory;
	class TermControl;
}

class JSONNode;
namespace xpm {
	using namespace std;
	
	class DocTableAccess : public DocAccess {
	public:
		DocTableAccess(conex::TermFactory* termFactory): DocAccess(termFactory) {Init();}
		void Init();
		virtual ~DocTableAccess();
		// need for api
		virtual int Load(XpmTermDoc& voc);
		virtual int Load(XpmTermDoc& voc, string signs);
		virtual bool Save(XpmTermDoc& voc, string& syntax);
		virtual string WriteTarget(XpmTermDoc& voc, string& syntax);
		void SetFilename(const char* filename);
		string GetFilename();
		bool SaveAs(XpmTermDoc& voc, const char* filename, string& syntax);
		void SetTermFactory(conex::TermFactory* termFactory);
		conex::TermFactory* termFactory();
		//parse the xml document with schema, return the true of false
		//serilizae xml 
		//parses
		int ParseWithJson(const char* filename, XpmTermDoc& voc);
		void ParseSignsBlocks(JSONNode n, XpmTermDoc& voc);
		void ParseSigns(JSONNode n, XpmTermBlock* block);
	private:
		conex::TermFactory* _termFactory;
		conex::TermControl* _termControl;
		string m_filename;
		string _outfile;
	};

}
#endif